package com.ror.java.se.data.type;

public class Demo02BasicTypeCast {
    public static void main(String[] args) {
        // float a = 1_0_1.1_1______1_2f;

        int pos = 0x12345678;
        int neg = 0x89abcdef;
        PrintBin(pos);
        System.out.println("========================");
        PrintBin(neg);

        int c = 0xffff;
        System.out.println(Integer.toBinaryString(c) + "\t" + Integer.toBinaryString((short) c));
        System.out.println(c + "\t" + (short) c);

        short d = -32767;
        System.out.println(Integer.toHexString(d));
    }

    static void PrintHex(int num) {
        System.out.println("Integer:\t0x" + Integer.toHexString(num));
        System.out.println("toShort:\t0x" + Integer.toHexString((short) num));
        System.out.println("toByte:\t\t0x" + Integer.toHexString((byte) num));
    }

    static void PrintBin(int num) {
        System.out.println("Integer:\t0b" + Integer.toBinaryString(num));
        System.out.println("toShort:\t0b" + Integer.toBinaryString((short) num));
        System.out.println("toByte:\t\t0b" + Integer.toBinaryString((byte) num));
    }
}
